package org.spbsu.apco.server.taskset;

import org.spbsu.apco.common.task.core.TaskDescriptor;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.util.Assert;

import java.util.Set;

/**
 * User: mikpan
 * Date: 1/21/13
 * Time: 7:39 PM
 */
public class BagOfTasks extends BaseTaskSet {
    private Set<TaskDescriptor> taskDescriptors;

    @Required
    public void setTaskDescriptors(Set<TaskDescriptor> taskDescriptors) {
        Assert.notEmpty(taskDescriptors, "Bag of taskDescriptors cannot be empty");
        this.taskDescriptors = taskDescriptors;
    }

    @Override
    public void initializeTasks() {
        for (TaskDescriptor taskDescriptor : taskDescriptors) {
            addLeafTask(taskDescriptor.getBaseTask(), taskDescriptor.getInput());
        }
    }

}
